import {
  apiBrandList,
  apiModelList,
  apiCustomerTypeList,
  apiDepartmentList,
  apiPositionList,
  apiCustomerProfessionTypeList
} from '@/common/constants/index'

export default {
  data () {
    return {
      brandOptions: [],
      customerTypeOptions: [],
      departmentOptions: [],
      positionOptions: [],
      professionOptions: []
    }
  },
  install (Vue) {
    Vue.prototype.getData = function (options) {
      var pagination = {
        callback: options,
        totalRecords: 0,
        totalPages: 1,
        pageSize: 10,
        currentPage: 1
      }
      return pagination
    }
    Vue.prototype.getBrandList = function () {
      var _that = this
      apiBrandList().then(response => {
        _that.brandOptions = response.data
      }).catch(() => {

      })
      return _that.brandOptions
    }
    Vue.prototype.getModelList = function (options) {
      var search = new Promise(function (resolve) {
        apiModelList(options).then(response => {
          resolve(response.data)
        }).catch(() => {
          resolve([])
        })
      })
      return search
    }
    Vue.prototype.getCustomerTypeList = function () {
      var _that = this
      apiCustomerTypeList().then(response => {
        _that.customerTypeOptions = response.data
      }).catch(() => {

      })
      return _that.customerTypeOptions
    }
    Vue.prototype.getDepartmentList = function () {
      var _that = this
      apiDepartmentList().then(response => {
        _that.departmentOptions = response.data
      }).catch(() => {

      })
      return _that.departmentOptions
    }
    Vue.prototype.getPositionList = function () {
      var _that = this
      apiPositionList().then(response => {
        _that.positionOptions = response.data
      }).catch(() => {

      })
      return _that.positionOptions
    }
    Vue.prototype.getCustomerProfessionTypeList = function () {
      var _that = this
      apiCustomerProfessionTypeList().then(response => {
        _that.professionOptions = response.data
      }).catch(() => {

      })
      return _that.professionOptions
    }
    Vue.prototype.getServiceType = function () {
      return [{id: 0, name: '保内'}, {id: 1, name: '保外'}]
    }
    Vue.prototype.getFultType = function () {
      return [{id: 1, name: '硬件故障'}, {id: 2, name: '软件故障'}, {id: 3, name: '人为损坏'}, {id: 4, name: '误报'}]
    }

    Vue.prototype.getHardwareRepairType = function () {
      return [{id: 1, name: '更换备机'},
        {id: 2, name: '更换部件'}]
    }

    Vue.prototype.getHardwareRepairType = function () {
      return [{id: 1, name: '更换备机'},
        {id: 2, name: '更换部件'}]
    }

    Vue.prototype.getSoftwareRepairType = function () {
      return [{id: 1, name: '刷机'},
        {id: 2, name: '升级'},
        {id: 3, name: '恢复出厂'}]
    }

    Vue.prototype.getInvoiceType = function () {
      return [{id: 0, name: '普通发票'},
        {id: 1, name: '增值税发票'}]
    }

    Vue.prototype.getRepairStatus = function () {
      return [{id: 0, name: '待修复'},
        {id: 1, name: '已修复'},
        {id: 2, name: '原物返还'}]
    }
  }
}
